package com.itheima.inputstreamreader;

import java.io.*;

public class Test2 {

    public static void main(String[] args) {

        //使用字符输入转换流InputStreamReader解决不同编码格式的乱码问题

        try (
                //1.提取文件的原始字节流
                InputStream is = new FileInputStream("io\\src\\poem_gbk.txt");

                //2.创建字符输入转换流对象，指定编码格式
                Reader isr = new InputStreamReader(is, "GBK");

                //3.创建缓冲字符输入流对象包装低级的字符输入流对象
                BufferedReader br = new BufferedReader(isr);
        ) {

            String line;
            while ((line = br.readLine()) != null) {
                System.out.println(line);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
